package com.vinci.handler;

import com.vinci.exception.TokenException;
import com.vinci.util.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 用户 token 过期
     * @return
     */
    @ExceptionHandler(value = TokenException.class)
    @ResponseBody
    public JsonObject tokenExpiredExceptionHandler(){
        log.warn("用户 token 过期");
       JsonObject jsonObject =  new JsonObject<>();
       jsonObject.setCode("B003");
       jsonObject.setMsg("token overdue");
       return jsonObject;
    }
}